﻿using DotNetty.Buffers;
using QQ.Client;
using QQ.Codecs;
using static QQ.Codecs.DotNettyByteBufferExtensions.LengthType;

namespace QQ.Packet.Request.TLV
{
    public class TLV0x124 : IRequest
    {
        private readonly QQDeviceConfig config;
        private IByteBuffer unknown { get; set; } = Unpooled.Buffer();
        public TLV0x124(QQDeviceConfig config)
        {
            this.config = config;
        }
        public IByteBuffer Serialize() => Unpooled.Buffer()
            .WriteBytesWithLength(config.osType.ToByteBuffer(), SHORT, limitLength: 16)
            .WriteBytesWithLength(config.release.ToByteBuffer(), SHORT, limitLength: 16)
            .WriteShort((short)config.networkType)
            .WriteBytesWithLength(config.simInfo.ToByteBuffer(), SHORT, limitLength: 16)
            .WriteBytesWithLength(unknown, SHORT, limitLength: 32)
            .WriteBytesWithLength(config.apn.ToByteBuffer(), SHORT, limitLength: 16);
    }
}